#include <iostream>
using namespace std;
int main()
{
    int light[1001];
    int i;
    int t;
    int n;
    char temp;
    int a, b;
    cin >> t;
    while (t--)
    {
        cin >> n;
        for (i = 0; i < 1001; i++)
            light[i] = 0;
        while (n--)
        {
            cin >> temp;
            cin >> a;
            cin >> b;
            for (i = a; i < b; i++)
                light[i]++;
        }
        for (i = 0; i < 1001; i++)
        {
            if (light[i] != 0)
                cout << (char)(light[i] - 1 + 'A');
        }
        cout << endl;
    }
    return 0;
}